package org.qiyu.live.user.provider;

import jakarta.annotation.Resource;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.qiyu.live.user.constants.UserTagsEnum;
import org.qiyu.live.user.dto.UserDTO;
import org.qiyu.live.user.dto.UserLoginDTO;
import org.qiyu.live.user.provider.service.IUserPhoneService;
import org.qiyu.live.user.provider.service.IUserService;
import org.qiyu.live.user.provider.service.IUserTagService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

/**
 * Created with IntelliJ IDEA.
 * Description: 用户中台的服务提供者
 * User: sfx
 * Date: 2023-09-12
 * Time: 17:11
 */
@SpringBootApplication
@EnableDubbo
@EnableDiscoveryClient
public class UserProviderApplication{
    //private static final Logger LOGGER = LoggerFactory.getLogger(UserProviderApplication.class);
    @Resource
    private IUserService userService;

    @Resource
    private IUserTagService userTagService;

    @Resource
    private IUserPhoneService userPhoneService;

    public static void main(String[] args) {
        /*
         * 指定使用的日志框架，否则将会告警
         * RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.InternalThreadLocalMap).
         * RocketMQLog:WARN Please initialize the logger system properly.
         */
        //System.setProperty("rocketmq.client.logUseSlf4j", "true");
        SpringApplication springApplication = new SpringApplication(UserProviderApplication.class);
        springApplication.setWebApplicationType(WebApplicationType.NONE);
        springApplication.run(args);
    }

//    @Override
//    public void run(String... args) throws Exception {
//        String phone = "13846076083";
//        UserLoginDTO login = userPhoneService.login(phone);
//        System.out.println(userPhoneService.queryByUserId(login.getUserId()));
//        System.out.println(userPhoneService.queryByUserId(login.getUserId()));
//        System.out.println(userPhoneService.queryByPhone(phone));
//        System.out.println(userPhoneService.queryByPhone(phone));
//    }

//    @Override
//    public void run(String... args) throws Exception {
//        Long userId = 1004L;
//        UserDTO userDTO = userService.getUserInfo(userId);
//        System.out.println(userTagService.setTag(userId, UserTagsEnum.IS_OLD_USER));//true
//        System.out.println(userTagService.containsTag(userId,UserTagsEnum.IS_OLD_USER));//true
//        System.out.println(userTagService.cancelTag(userId,UserTagsEnum.IS_OLD_USER));//true
//        System.out.println(userTagService.containsTag(userId,UserTagsEnum.IS_OLD_USER));//false
//        System.out.println("当前用户是否拥有 is_vip标签：" + userTagService.containsTag(userId, UserTagsEnum.IS_VIP));//false
//        System.out.println(userTagService.setTag(userId, UserTagsEnum.IS_OLD_USER));//true
//        System.out.println("当前用户是否拥有 is_old_user标签：" + userTagService.containsTag(userId, UserTagsEnum.IS_OLD_USER));//true
//        System.out.println("================================");
//        System.out.println(userTagService.cancelTag(userId, UserTagsEnum.IS_VIP));//false
//        System.out.println("当前用户是否拥有 is_rich标签：" + userTagService.containsTag(userId, UserTagsEnum.IS_RICH));//false
//        System.out.println(userTagService.cancelTag(userId, UserTagsEnum.IS_VIP));//false
//        System.out.println("当前用户是否拥有 is_vip标签：" + userTagService.containsTag(userId, UserTagsEnum.IS_VIP));//false
//        System.out.println(userTagService.cancelTag(userId, UserTagsEnum.IS_OLD_USER));//false
//        System.out.println("当前用户是否拥有 is_old_user标签：" + userTagService.containsTag(userId, UserTagsEnum.IS_OLD_USER));//false
//    }
}